package org.anno.chunkdb;

import java.util.Iterator;

/**
 * Scans rows in a {@link LightChunk} in natural order.
 */
public class ChunkScanPlan extends QueryPlan {

  private final QueryPlanSupport planSupport;

  public ChunkScanPlan(Metadata.Table table, byte[] flatArray) {
    super(table, 0);
    planSupport = new LightChunk(flatArray, this.table);
  }

  @Override
  public void accept(ResponseVisitor responseVisitor) {
    acceptForAllColumns(table, responseVisitor);
    responseVisitor.visitRows(new Iterable<Host<RowVisitor>>() {
      public Iterator<Host<RowVisitor>> iterator() {
        return planSupport.iterator();
      }
    });
  }
}
